package com.google.gwt.sample.dynatablerf.server.business;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;

public class ControladorFactory {

	public static <T> T getControlador(Class<T> clazz) {
		HttpServletRequest request = RequestFactoryServlet
				.getThreadLocalRequest();
		ServletContext servletContext = request.getSession()
				.getServletContext();
		ApplicationContext ctx = WebApplicationContextUtils
				.getWebApplicationContext(servletContext);
		return ctx.getBean(clazz);
	}
}